﻿<?php
require_once('common.php');
echo "<h2>fopen获取本地文件</h2>";
/*fopen打开本地文件*/
$filename = "test.html";
$fp = fopen($filename, "r");
$fc = "";
while (!feof($fp)) {
    $fc .= fgets($fp, 1024);
}
fclose($fp);
echo "<h3>本地文件内容：</h3>" . $fc;

/*fopen打开远程url*/
echo "<h2>fopen打开远程url</h2>";
$filename = getHost() . "spiders/test.html";
$fp = fopen($filename, "r");
echo "<h3>输出stream_get_meta_data</h3>";
dumpArr(stream_get_meta_data($fp));
$fc = "";
while (!feof($fp)) {
    $fc = fgets($fp, 1024);
}
fclose($fp);
echo "<h3>输出http_response_header</h3>";
dumpout($http_response_header);
echo "<h3>远程url内容：</h3>".$fc;

?>
